/** ------------------------------------------------------------------------
 *	VisualGroup JavaScript prototype Classes, version draf
 *  (c) 2006 Bill Vison <vison_ruan@126.com>
 *
 *
/*--------------------------------------------------------------------------*/


/**
 * 
 * @Prototype Class : "Vsg.Event.CheckBoxEvent"
 *						that will be render event style
 * @prerequire class : 	"Vsg.Common.Logger"
 *						
 */
using("Vsg.Common.Logger");
 
Vsg.Event.FormEvent = Class.create();

Vsg.Event.FormEvent.SUBMIT = "submit";
Vsg.Event.FormEvent.RESET = "reset";

Vsg.Event.FormEvent.prototype.initialize = function() {
	var $thisForm = null;
	
	var $refSubHandlerArray = new Array();
	
	this.setForm = function($form) {
		$thisForm = $form;
	}

	function setHandler($name , $handler) {
		$refSubHandlerArray[$name] = $handler;
	}
	this.setHandler = setHandler;

	function getHandler($name) {
		return $refSubHandlerArray[$name];
	}
	this.getHandler = getHandler;
	
	this.submit = function() {
		var refHandler = getHandler(Vsg.Event.FormEvent.SUBMIT);
		try {
			if (refHandler == null) {
				throw "submit handler is null";
			}
			refHandler.call(refHandler,$thisForm);
		} catch (ex) {
			$thisForm.submit();	
		}
	}
	
	this.reset = function() {
		$thisForm.reset();
	}

}

